package com.huahang.fashionpress.controller;

import com.huahang.fashionpress.model.Category;
import com.huahang.fashionpress.service.impl.CategoryServicelImpl;
import com.huahang.fashionpress.service.impl.SingleServiceImpl;
import com.huahang.fashionpress.vo.ProductSingleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * 单个商品控制页面
 * @author : 王翰聪
 * @since : 2019/08/24
 * @version : 1.0
 */
@Controller
@RequestMapping("/single")
public class SingleController {
    @Autowired
    private SingleServiceImpl singleService;
    @Autowired
    private CategoryServicelImpl categoryService;

    @RequestMapping("/")
    public ModelAndView getSingleView(String productId, Map map){
        ProductSingleVO productSingleVO = singleService.getSingleProduct(productId);
        List<Category> categoryList = categoryService.SelectallCategory();


        map.put("productId", productSingleVO.getProductId());
        map.put("productSingleVO", productSingleVO);
        map.put("categoryList", categoryList);
        return new ModelAndView("client/single", map);
    }

}
